Skip to content

Add Bivariate Distributions lecture - #837

Merged
jstac merged 3 commits into
mainfrom
bivariate-distributions-lecture
Aug 17, 2026
Merged

Add Bivariate Distributions lecture#837
jstac merged 3 commits into
mainfrom
bivariate-distributions-lecture

Conversation

@jstac

@jstac jstac commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a new lecture, Bivariate Distributions, placed after fitting_distributions and before lln_clt in the Probability and Distributions part.

The three existing lectures in that part (prob_dist, observed_distributions, fitting_distributions) all treat one variable at a time. This lecture is a quick, elementary bridge to pairs of variables, aimed at applied readers, before the series moves on to simple_linear_regression/mle.

Contents

  • Joint and marginal distributions (discrete case first, then continuous)
  • Independence, covariance, and correlation
  • Two ways joint distributions arise: independent components, and Y = aX + b + U
  • The bivariate normal distribution (density, contour plots, a 3D surface plot), including a counterexample showing that normal marginals do not imply joint normality
  • Back to real data: revisits the Ames house price dataset from observed_distributions/fitting_distributions, now looking at price vs. floor area jointly (hexbin/jointplot, sample correlation)
  • Fitting a bivariate normal by the method of moments
  • A closing preview showing that the bivariate normal's conditional mean coincides exactly with the OLS regression line, handing off to simple_linear_regression
  • One exercise (Amazon vs. Costco monthly returns), with solution

Verification

  • Re-executed all code cells (28 cells, including the live yfinance download in the exercise) standalone — clean run, no errors
  • Built the page locally with jupyter-book build bivariate_dist.md — notebook executed successfully (8.15s), HTML rendered correctly
  • Rendered the built HTML with headless Chromium and visually inspected every section: math, figure captions/numbering, notes, exercise/solution admonitions all render as expected
  • Confirmed in the built HTML that the exercise-solution figure is uncaptioned (no <figure>/<figcaption> wrapper), per the manual's guidance that captioned figures inside solution directives break the PDF build
  • The only build warnings are unresolved cross-page {doc} links and a bibtex key, expected for a standalone single-page build outside the full toc/bibliography context

🤖 Generated with Claude Code

Adds a new lecture introducing bivariate distributions, placed after
fitting_distributions and before lln_clt in the Probability and
Distributions part of the toc.

Covers joint/marginal distributions (discrete and continuous), independence,
covariance and correlation, ways joint distributions arise (independent
components; Y = aX + b + U), the bivariate normal distribution, and a
counterexample showing normal marginals don't imply joint normality. Moves
to observed data using the Ames house price dataset already used in
observed_distributions/fitting_distributions, fits a bivariate normal by
the method of moments, and closes with a preview showing the bivariate
normal's conditional mean coincides with the OLS line, handing off to
simple_linear_regression.

Built and rendered locally to verify execution and output.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@netlify

netlify Bot commented Aug 15, 2026

Copy link
Copy Markdown

Deploy Preview for taupe-gaufre-c4e660 ready!

Name Link
🔨 Latest commit 2dfbb65
🔍 Latest deploy log https://app.netlify.com/projects/taupe-gaufre-c4e660/deploys/6a8255b75bde7a000930362c
😎 Deploy Preview https://deploy-preview-837--taupe-gaufre-c4e660.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions

github-actions Bot commented Aug 15, 2026

Copy link
Copy Markdown

@github-actions
github-actions Bot temporarily deployed to pull request August 15, 2026 21:55 Inactive
@github-actions
github-actions Bot temporarily deployed to pull request August 15, 2026 21:56 Inactive
- Move marginal distributions into the Discrete case and Continuous case
  subsections directly, rather than as a separate section after both, so
  discrete marginals (sums, bar charts) come first and continuous marginals
  (integrals, density curves) mirror them.
- Split the Ames discrete example by mean instead of median, so the
  marginals are visibly asymmetric (~45%/38%) rather than ~50/50 by
  construction, tying back to the right-skew lesson from
  observed_distributions.
- Add a heatmap of the joint PMF in the discrete case, and introduce the
  bivariate normal density (with 3D surface and contour plots) directly in
  the continuous case rather than in a separate later section.
- Rename "The bivariate normal distribution" to "Back to the normal
  distribution", now picking up after Independence/Covariance/How joint
  distributions arise with the properties note, sample-draws figure, and
  the "word of caution" counterexample.
- Explain what np.corrcoef returns and why [0, 1] is indexed, the first
  time it's used.
- In "A word of caution": use 1 directly instead of an unnecessary
  parameter c, fix a leftover "houses" reference from the Ames example,
  and switch the counterexample to sns.jointplot so the normal marginals
  and non-normal joint are visible in one figure.

Re-executed the full notebook (31 code cells) after each change; verified
with a local jupyter-book build.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@github-actions
github-actions Bot temporarily deployed to pull request August 16, 2026 22:01 Inactive
@github-actions
github-actions Bot temporarily deployed to pull request August 16, 2026 22:03 Inactive
sns.heatmap puts row 0 at the top by default, so with x=0 (below mean)
at the top and x=1 (above mean) at the bottom, the diagonal of large
cells ran top-left to bottom-right --- visually reading as a negative
correlation even though the data is positively correlated. Add
ax.invert_yaxis() to both heatmaps (the discrete joint heatmap and the
actual-vs-independent comparison) so x increases upward, matching how
a standard scatter plot reads.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@github-actions
github-actions Bot temporarily deployed to pull request August 17, 2026 00:38 Inactive
@jstac
jstac merged commit 8e74ab4 into main Aug 17, 2026
8 checks passed
@jstac
jstac deleted the bivariate-distributions-lecture branch August 17, 2026 00:48
@mmcky

mmcky commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

✅ Translation sync completed (zh-cn)

Target repo: QuantEcon/lecture-intro.zh-cn
Translation PR: QuantEcon/lecture-intro.zh-cn#296
Files synced (2):

  • lectures/bivariate_dist.md
  • lectures/_toc.yml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants